<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page import="javax.portlet.*" %>
<%@ page import="pits.dto.EditTakenCourseInfoDTO" %>
<%@ page import="pits.dao.EditTakenCourseInfoDAO" %>
<%@ page import="pits.util.Constants" %>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>

<portlet:defineObjects />

<head>

<script type="text/javascript" src='<%=renderRequest.getContextPath() + "/js/simpletreemenu.js" %>'></script>
<link type="text/css" href='<%=renderRequest.getContextPath() + "/css/simpletree.css" %>' />

<script type="text/javascript" src='<%=renderRequest.getContextPath() + "/js/calendarDateInput.js" %>' ></script>

<script type="text/javascript">
	function getForm(namespace, name) {
		return document.forms[namespace + name];
	}
	
	function submitForm(namespace, name, action) {
		var frm = getForm(namespace, name);
		frm.txtAction.value = action;
		frm.submitLink.value = "EditTakenCourseInfo.jsp";

		if (name != "myForm") {
			if (frm.selectGrade.value == "Other") {
				frm.grade.value = frm.otherGrade.value;
			}
			else {
				frm.grade.value = frm.selectGrade.value;
			}
		}
		frm.submit();
	}

</script>

<link type="text/css" rel="stylesheet" href='<%=renderRequest.getContextPath() + "/css/style.css" %>' media="screen" />
</head>
<body>
<form name="<portlet:namespace/>myForm" action="<portlet:actionURL/>" method="POST">
<input type="hidden" name="txtAction"/>
<input type="hidden" name="submitLink"/>
<p align="right">
	You are logging in as 
	<a href="#" onclick="submitForm('<portlet:namespace/>', 'myForm', 'getEmployeeInfo')"><b>${sessionScope.userName}</b></a>
	! &nbsp;
	<a href="#" onclick="submitForm('<portlet:namespace/>', 'myForm', 'home')">Home</a>
	| &nbsp;
	<a href="#" onclick="submitForm('<portlet:namespace/>', 'myForm', 'logout')">Logout</a>
</p>
</form>

<form name="<portlet:namespace/>editTakenCourseInfoForm" action="<portlet:actionURL/>" method="POST">
<input type="hidden" name="txtAction" />
<input type="hidden" name="submitLink" />
<table align="center">
	<tr class="title">
		<td colspan="2">
			<img src='<%=renderRequest.getContextPath() + "/img/HCMUTLogo.jpg" %>' />
			<h1><a href="#">Personal information tracking system </a></h1>
			<p>exploit the value of data</p>
			<hr />
		</td>
	</tr>
	
	<tr>
		<td>
			<table border="1">
				<tr>
					<td><h2 class="title">Course  Information</h2></td>
				</tr>
					
				<tr>
					<td><p><em>General Information </em></p></td>
				</tr>
				<%--
					Enumeration<String> attNames = request.getAttributeNames();
					while (attNames.hasMoreElements()) {
						attNames.nextElement().toString();
					}
					Enumeration<String> sesNames = session.getAttributeNames();
					while (sesNames.hasMoreElements()) {
						sesNames.nextElement().toString();
					}
				--%>
				<%
					EditTakenCourseInfoDTO takenCourse = new EditTakenCourseInfoDAO().getData("" + session.getAttribute("courseID"), "" + session.getAttribute("empID"));
				%>
				
				<tr>
					<td>
						<table border="1" width="100%">							
							<tr>
								<td align="left" valign="bottom">&nbsp;Name&nbsp;</td>
								<td align="left" valign="middle" colspan="2">
									<%=takenCourse.getCourseName() %>
								</td>
							</tr><tr>
								<td align="left" valign="bottom">&nbsp;Description&nbsp;</td>
								<td align="left" valign="middle" colspan="2">
									<%=takenCourse.getDescription() %>
								</td>
							</tr>
							<tr> 
								<td align="left" valign="bottom">&nbsp;Department/Institute Issued &nbsp;</td>
								<td colspan="2" align="left" valign="middle">
									<%=takenCourse.getDepartName() %>
								</td>						
							</tr>
							<tr>
								<td align="left" valign="bottom">&nbsp;Training Period</td>
								<td align="left" valign="middle" colspan="2">
									<%=takenCourse.getPeriod() %>
								</td>
							</tr>
							<tr>
								<td align="left" valign="middle">&nbsp;Date Issused &nbsp;</td>
								<td colspan="2" align="left" valign="bottom">&nbsp;
									<script>DateInput('dateIssused', true, 'DD/MM/YYYY', '<%= request.getContextPath() %>', '<%=takenCourse.getDateIssused() %>');</script>
								</td>
							</tr>
							
							<tr>
								<td align="left" valign="bottom">&nbsp;Grade&nbsp;</td>
								<td align="left" valign="bottom">
									<input name="grade" type="hidden" />
									<select name="selectGrade" id="selectGrade" onchange="
										if(this.value=='Other'){
											this.form.otherGrade.style.visibility='visible';
											this.form.otherGrade.focus();
										}
										else{
											this.form.otherGrade.style.visibility='hidden';
										}
									">
										<option value="Excellent">Excellent</option>
										<option value="Good">Good</option>
										<option value="Average">Average</option>
										<option value="Other">Other</option>
									</select>
									<script type="text/javascript">
										for (i = 0; i < document.getElementById('selectGrade').length; i++) {
											if (document.getElementById('selectGrade').options[i].value == '<%=takenCourse.getGrade() %>') {
												document.getElementById('selectGrade').selectedIndex = i;
												break;
											}
										}
									</script>
									<input name="otherGrade" type="text" style="visibility:hidden" />
								</td>
							</tr>

				  			<tr align="left" valign="bottom">
						  		<td colspan="4">
							  		<input type="button" value="Update" onclick="
							  			submitForm('<portlet:namespace/>','editTakenCourseInfoForm','updateTakenCourse')
							  		"/>
							  		<input type="button" value="Cancel" onclick="
							  			submitForm('<portlet:namespace/>','editTakenCourseInfoForm','cancel')
							  		"/>
						  		</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>			
		</td>
	</tr>
	
	<tr>
		<td colspan="2">
			<div style="clear: both;">&nbsp;</div>
			<div id="footer"><p>Development by HCMUT Project 1 Spring 2010 Group 4</p>
			</div>
		</td>
	</tr>
</table>
</form>
</body>
